<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%@page import="com.neuedu.page.Page" %>
	<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="width=device-width, 
			initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta charset="utf-8" />
		<title>商品的浏览</title>
		<!--
			link:标签，用于调用外部css样式
			 属性：rel：连接一个样式表
			     href：css的地址：相对路径
		-->
		
		<link rel="stylesheet"  type="text/css"  media="screen" href="css/index.css" />
	</head>
	<body>
	<!--  
	  非java语言的使用：jstl标签+el表达式
	-->
   <%-- ${p} --%>
		<div class="allpage">
			<jsp:include page="lay/head.jsp"></jsp:include>
		
			<div class="main">
				
				 <%@include file="lay/left.jsp" %>
				<div class="btnleftdisply" >
					<img id="displayimg" src="img/三角 (2).svg" onclick="leftdisply()"/>				</div>
				<div class="main_right">
					<div class="goodsall">
					
					
				<c:forEach items="${p.data}" var="good">
				
					
					<div class="goods">
						<div>
							<img src="img/${good.gmainimg }"  />
						</div>
						<div>
							<div>加入购物车</div>
							<div>${good.gname }&nbsp;&nbsp;8/斤&nbsp;&nbsp;限购5斤</div>
						</div>
					</div>
					
					</c:forEach>
					
					</div>
					<div class="pagebuts">
						<input type="button" value="第一页" onclick="first()">
						<input type="button" value="上一页" onclick="pre()">
						<input type="button" value="下一页" onclick="next()">
						<input type="button" value="最后一页" onclick="last()">
					</div>
					<script>
					var cur=${p.currentpage};
					var lastp=${p.pageSum};
					var buts=document.getElementsByClassName("pagebuts")[0].children;
					console.log(buts);
					if(cur==1){
						buts[0].setAttribute("disabled","disabled");
						buts[1].setAttribute("disabled","disabled");
					}else{
						buts[0].removeAttribute("disabled");
						buts[1].removeAttribute("disabled");
					}
					
					if(cur==lastp){
						buts[2].setAttribute("disabled","disabled");
						buts[3].setAttribute("disabled","disabled");
					}else{
						buts[2].removeAttribute("disabled");
						buts[3].removeAttribute("disabled");
					}
					
					function next(){
						window.location.href="list.goods?n="+(cur+1);
					}
					
					
					
					function pre(){
						window.location.href="list.goods?n="+(cur-1);
					}
					
					function first(){
						window.location.href="list.goods?n="+1;
					}
					function last(){
						window.location.href="list.goods?n="+lastp;
					}
					</script>
				</div>
				
			</div>
			
			<div class="foot">
				<div>制作人：刘岩</div>
				  <div>邮箱地址：574156761@qq.com</div>
			      <div>&copy;版权信息</div>
			</div>
			
		</div>
		
		
		<script>
		
			
			
			
			/*菜单的显示和隐藏*/
			function leftdisply(){
				var main_left=document.getElementsByClassName("main_left")[0];
				var main_right=document.getElementsByClassName("main_right")[0];
				
				
				var displayimg=document.getElementById("displayimg");
				if(main_left.getAttribute("style")=="display: none;"){
					main_left.setAttribute("style","display: block;")
					main_right.setAttribute("style","width: 75%;")
					displayimg.setAttribute("src","img/三角 (2).svg")
				}else{
					main_left.setAttribute("style","display: none;")
					main_right.setAttribute("style","width: 95%;")
				    displayimg.setAttribute("src","img/三角 (1).svg")
				}
			}
		</script>
	</body>
</html>
